import serveUrl from "@/config/serverAddress"; // 接口域名列表
import axios from "@/config/http"; // 导入http中创建的axios实例

const publicApi = {

  /**
   * 公用接口
   * @api{property} 获取城市信息
   */
  CompanyGetProvinces() {
    return axios.get(`${serveUrl.cs}/Company/Provinces`, { timeout: 100000 * 30 });
  },

  /**
   * 公用接口
   * @api{property} 获取城市信息
   */
  GetProvinces() {
    return axios.get(`${serveUrl.cs}/Common/Provinces`, { timeout: 100000 * 30 });
  },
  //  * @api{property} 获取公司部门子集树
  GetSubCompanyView(params) {
    return axios.get(`${serveUrl.cs}/Common/GetSubCompanyView`, { params });
  },
  //  * @api{property} 获取公司、子集、部门树
  GetSubCompanyDataView(params) {
    return axios.get(`${serveUrl.cs}/Common/GetSubCompanyDataView`, { params });
  },
  //  * @api{property} 获取权限列表
  GetActionInfo(params) {
    return axios.get(`${serveUrl.cs}/Authority/GetModuleAuthorityTree`, { params });
  },
  //  * @api{property} 企业版登录
  EnterpriseLogin(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/EnterpriseLogin`, { params });
  },
  //  * @api{property} 官网登录
  Login(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/Login`, { params });
  },
  //  * @api{property} 官网登录
  LoginNonTrace(data) {
    return axios.post(
      `${serveUrl.ac}/connect/token`,
      Object.keys(data)
        .map((key) => `${key}=${data[key]}`)
        .join("&"),
      {
        headers: {
          "Content-Type": "application/x-www-form-urlencoded",
        },
      }
    );
  },
  //  * @api{property} 官网注册
  Register(params) {
    return axios.post(`${serveUrl.cs}/ClientUser/Register`, params);
  },
  //  * @api{property} 获取行业数据
  GetCompanyIndustryTemp(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/GetCompanyIndustryTemp`, { params });
  },
  //  * @api{property} 修改公司所属行业或者是否开启水印
  EditIndustryOrWatermark(params) {
    return axios.put(`${serveUrl.cs}/Company/EditIndustryOrWatermark?industryid=${params.industryid}&isOpenWatermark=${params.isOpenWatermark}`);
  },
  //获取代办事项列表
  GetBacklogList(params) {
    return axios.get(`${serveUrl.cs}/Backlog/GetBacklogList`, { params });
  },
  //添加代办事项
  GetAddBacklog(params) {
    return axios.post(`${serveUrl.cs}/Backlog/AddBacklog`, params);
  },
  //删除代办事项
  DeleteBacklog(params) {
    return axios.delete(`${serveUrl.cs}/Backlog/DeleteBacklog`, { params });
  },
  //更新代办事项
  UpdateBacklog(data) {
    return axios.put(`${serveUrl.cs}/Backlog/UpdateBacklog?backlogId=${data}`);
  },

  //  * @api{property} 获取pisiid登陆进销存
  SyncPsi(params) {
    return axios.get(`${serveUrl.cs}/Company/SyncPsi`, { params });
  },
  //  获取验证码
  getiphone(params) {
    return axios.get(`${serveUrl.cs}/Common/VerificationCode`, { params });
  },
  //  * @api{property} 根据用户指定企业登录
  LoginSite(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/LoginSite`, { params });
  },
  //  * @api{property} code登录
  LoginWeChat(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/LoginWeChat`, { params });
  },
  //  获取登录验证码
  getSigninIphone(params) {
    return axios.get(`${serveUrl.ac}/Common/GetVerificationCode`, { params });
  },
  // 根据手机号进行登录
  LoginMobile(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/LoginMobile?phone=${params.phone}&code=${params.code}&singleVal=${params.singleVal || ""}&machineVal=${params.machineVal}`);
  },
  // 根据token登录
  LoginByToken(params) {
    return axios.get(`${serveUrl.cs}/ClientUser/LoginByToken`, { params });
  },

  /**
   * 公用接口
   * @api{property}  上传
   */
  uploadOssFile(params) {
    return axios.post(`${serveUrl.cs}/Common/uploadOssFile`, params);
  },

  /**
   * 公用接口
   * @api{property}  批量上传
   */
  uploadMultipleFile(params) {
    return axios.post(`${serveUrl.cs}/Common/uploadMultipleFile`, params);
  },
  //  * @api{property} 导入excel数据
  importFile(params, subCompanyId) {
    return axios.post(`${serveUrl.cs}/Common/importFile?subCompanyId=${subCompanyId}`, params);
  },
  //  * @api{property} 导出excel数据
  exportFile(params) {
    return `${serveUrl.cs}/Common/exportFile?subCompanyId=${params.subCompanyId}`;
    // return axios.post(`${serveUrl.cs}/Common/exportFile`, params)
  },
  //  获取当前样式
  GetWebPageStyle(params) {
    return axios.get(`${serveUrl.cs}/Common/GetWebPageStyle`, { params });
  },
  // 设置当前样式
  SettingWebPageStyle(userId, params) {
    return axios.post(`${serveUrl.cs}/Common/SettingWebPageStyle?userid=${userId}`, params);
  },

  //  获取模板权限树  - 后端使用
  GetTemplateAuthorityTree(params) {
    return axios.get(`${serveUrl.cs}/Authority/GetTemplateAuthorityTree`, { params });
  },
  //  修改模板权限树  - 后端使用
  TemplateAuthorityEdit(Obj, params) {
    return axios.post(`${serveUrl.cs}/Authority/Edit?sqlType=${Obj.sqlType}&type=${Obj.type}`, params);
  },
  //  修改模板权限树 无代码  - 后端使用
  EditAuthority(Obj, params) {
    return axios.post(`${serveUrl.cs}/Authority/EditAuthority?sqlType=${Obj.sqlType}`, params);
  },
  //  给所有企业号同步新增的权限数据  - 后端使用
  SyncAuthority(Obj, params) {
    return axios.post(`${serveUrl.cs}/Authority/SyncAuthority?type=${Obj.type}`, params);
  },
  //  生产环境注册成功-调用 http://hc.yundaizhang.com
  GetWebService(params) {
    return axios.get(`https://crmht.yundaizhang.com.cn:8444/WebService/AddSCListAPI`, { params });
  },

  /**
   * @description 第三方登录
   * @param {*} params
   * @returns
   */
  LoginCustomer(params) {
    return axios.get(`${serveUrl.ac}/ClientUser/LoginCustomer`, { params });
  },

  /**
   * @description 返回登录用户信息
   * @param {*} params
   * @returns
   */
  GetLoginUserInfo(params) {
    return axios.get(`${serveUrl.cs}/User/GetLoginUserInfo`, { params });
  },

  LoginQRcode(params) {
    return axios.get(`${serveUrl.cs}/WeChat/LoginQRcode`, { params });
  },
  CheckUserLogin(params) {
    return axios.get(`${serveUrl.cs}/WeChat/CheckUserLogin`, { params });
  },
  //首页考勤管理
  GetEmployeHoliday(params) {
    return axios.get(`${serveUrl.kq}/Common/GetEmployeHoliday`, { params });
  },
  //日打卡明细
  GetPrintingDate(params) {
    return axios.get(`${serveUrl.kq}/Common/GetPrintingDate`, { params });
  },
  //获取用户详细信息
  GetLoginUserSpecificInfo(params) {
    return axios.get(`${serveUrl.cs}/User/GetLoginUserSpecificInfo`, { params });
  },
  //登录页获取图标
  AgentLonginOem(params) {
    return axios.get(`${serveUrl.dgj}/ClientUser/AgentLonginOem`, { params });
  },
  //检查是否到期
  CheckExpire(params) {
    return axios.get(`${serveUrl.cs}/Common/GetServiceInform`, { params });
  },
  
  //已读弹窗提醒
  ReadWindow(params) {
    return axios.post(`${serveUrl.cs}/Common/EditServiceInform`, { params });
  },
};

export default publicApi;
